import java.util.Scanner;

/**
 * @author gao
 * @date 2025/11/8 12:49
 */

public class Solution {
    public String minWindow(String s, String t) {
        char[] chS = s.toCharArray();
        char[] chT = t.toCharArray();

        // 统计t中每个字符出现的次数
        int[] hash1 = new int[128];
        // 统计s中每个字符出现的次数
        int kinds = 0;
        for (char ch : chT) {
            if (hash1[ch] == 0) {
                kinds++;
            }
            hash1[ch]++;
        }

        // 记录当前窗口中字符出现的次数
        int[] hash2 = new int[128];
        int minLen = Integer.MAX_VALUE, begin = -1;

        for (int left = 0, right = 0, count = 0; right < chS.length; right++) {
            // 将right指向的字符加入窗口
            char in = chS[right];
            if (++hash2[in] == hash1[in]) {
                count++;
            }

            // 当窗口中包含t中所有字符时，尝试缩小窗口
            while (kinds == count) {
                if (right - left + 1 < minLen) {
                    begin = left;
                    minLen = right - left + 1;
                }
                char out = chS[left++];
                if (hash2[out]-- == hash1[out]) {
                    count--;
                }
            }
        }
        if (begin == -1) {
            return "";
        } else {
            return s.substring(begin, begin + minLen);
        }
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while (in.hasNext()) {
            String s = in.nextLine();
            String t = in.nextLine();
            Solution solution = new Solution();
            System.out.println(solution.minWindow(s, t));
        }
    }
}